function editProfile(){
    document.getElementById('personalInfoFields').disabled = false;
}
function populateUserInfo() {
    var who = JSON.parse(localStorage.getItem("loggedinUser")); 
    var users = JSON.parse(localStorage.getItem("users")); 
    //find the person who is logged in
    const user = users.find(u => u.email === who["email"]); 

    document.getElementById('nameInput').value =  user['name'];
    document.getElementById('locationInput').value =  user['location'];
    document.getElementById('weightInput').value =  user['weight'];
    document.getElementById('foodInput').value =  user['food'];


}
populateUserInfo();
function saveProfile(){
    const name = document.getElementById('nameInput').value;
    const location = document.getElementById('locationInput').value;
    const weight = document.getElementById('weightInput').value;
    const food = document.getElementById('foodInput').value;

    var who = JSON.parse(localStorage.getItem("loggedinUser"));
    var users = JSON.parse(localStorage.getItem("users"));
    const user = users.find(u => u.email === who["email"]);

    user['name'] = name;
    user['location'] = location;
    user['weight'] = weight;
    user['like food'] = food

    localStorage.setItem("loggedinUser", JSON.stringify(user));
    localStorage.setItem("users", JSON.stringify(users));

    alert('Personal info Saved');

    document.getElementById('personalInfoFields').disabled = true;
}